angular.module('${menuCode}')
.controller("${widgetCode}Ctrl",function($scope,AppKit){
	$scope.loadData = function(){
		var url = '/portal/index?MobileInformationsDataProvider&actionType=getKnowledgeInformation&ID='+$scope.currentInfoId;
		var promise = AppKit.getJsonApi(url);
		promise.success(function(rspJson){
			$scope.id = rspJson.id;
			$scope.title = rspJson.title;
			$scope.createTime = rspJson.createTime;
			$scope.content = rspJson.content;
			$scope.isPraised = rspJson.isPraised;
			$scope.isFavorited = rspJson.isFavorited;
		});
	}
	$scope.loadData();
	
	$scope.praiseInfo = {"infoId":$scope.currentInfoId};
	$scope.doPraise = function(){
		var url = "/portal/index?ContentProvider&actionType=mobileChangePraiseCount"
		AppKit.postJsonApi(url,$scope.praiseInfo).then(function(response){
			if ("success" == response.data){
				$scope.loadData();	
				if($scope.isPraised == 'N'){
					AppKit.successPopup({"title":"点赞成功"});	
				}else{
					AppKit.successPopup({"title":"取消成功"});	
				}
			}else{
				AppKit.errorPopup();
			}
		});
	}
	
	$scope.favoriteInfo = {"infoId":$scope.currentInfoId,"title":"","favType":"OTHERS"};
	$scope.doFavorite = function(){
		var url = "/portal/index?ContentProvider&actionType=mobileAddToFavorite"
		AppKit.postJsonApi(url,$scope.favoriteInfo).then(function(response){
			if ("success" == response.data){
				$scope.loadData();
				if($scope.isFavorited == 'N'){
					AppKit.successPopup({"title":"收藏成功"});	
				}else{
					AppKit.successPopup({"title":"取消成功"});	
				}			
			}else{
				AppKit.errorPopup();
			}
		});
	}
});